findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1)
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2)
b1 <- coef(m1)[c("numpar:refmon_adj_imp0","refmon_adj_imp0")]
b2 <- coef(m2)[c("numpar:refmon_adj_imp0","refmon_adj_imp0")]
V1 <- vcov(m1)[c("numpar:refmon_adj_imp0","refmon_adj_imp0"),c("numpar:refmon_adj_imp0","refmon_adj_imp0")]
V2 <- vcov(m2)[c("numpar:refmon_adj_imp0","refmon_adj_imp0"),c("numpar:refmon_adj_imp0","refmon_adj_imp0")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:refmon_adj_imp0","refmon_adj_imp0")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:refmon_adj_imp0","refmon_adj_imp0")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
}
dev.off()
pdf("out/Time_stable_woWWII.pdf",width=19,height=6)
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
}
dev.off()
df2latex(outi)
xtable(outi)
library(xtable)
xtable(outi)
outi <- round(psych::describe(findat_oLG[,c("dlnexp_pc","year","numpar", "llnexp_pc", "index_law_init","index_law_ref",
"refmon_adj_imp0", "sec_sh", "fir_sh", "deprat", "babydeathratio_impute",
"left", "PR", "phydens", "lnpop", "lnfed_mix", "fisrul")], skew=FALSE, check=TRUE),1)
as.matrix(outi)
xtable(outi)
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
}
y <- 1930
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
y <- 1940
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
y <- 1990
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
y <- 2000
y <- 2000
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
}
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
print(y)
}
y
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1)
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2)
y
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time1$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
table(findat_time2$year)
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time2$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
print(y)
}
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time2$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
print(y)
}
dev.off()
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time2$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
print(y)
}
pdf("out/Time_stable_woWWII.pdf",width=19,height=6)
par(family="CMU Serif", mar=c(5.1, 5.1, 0, 2.1))
move.d <- 0.4
plot(0,0,xlim=c(1870,2005), ylim=c(-1,1), bty="n", xlab="",ylab=expression(hat(beta)[early]-hat(beta)[late]))
N.sim <- 2000
for (y in seq(1870,2000,by = 10)){
findat_time1 <- findat_oLG[findat_oLG$year<=y,]
findat_time2 <- findat_oLG[findat_oLG$year>y,]
m1 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time1[findat_time1$year!=1935 &findat_time1$year!=1940 & findat_time1$year!=1945 ,])
m2 <- lm(dlnexp_pc~factor(canton)+factor(year)+numpar+llnexp_pc+index_law_init*numpar+refmon_adj_imp0*numpar+I(finex==0)+index_law_ref*numpar+sec_sh+
fir_sh+deprat+babydeathratio_impute+left+PR+phydens+lnpop+lnfed_mix, findat_time2[findat_time2$year!=1935 &findat_time2$year!=1940 & findat_time2$year!=1945 ,])
b1 <- coef(m1)[c("numpar:index_law_init","index_law_init")]
b2 <- coef(m2)[c("numpar:index_law_init","index_law_init")]
V1 <- vcov(m1)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
V2 <- vcov(m2)[c("numpar:index_law_init","index_law_init"),c("numpar:index_law_init","index_law_init")]
BETA1 <- mvrnorm(N.sim, b1, V1)
BETA2 <- mvrnorm(N.sim, b2, V2)
B1 <- BETA1[,c("numpar:index_law_init","index_law_init")]
BB1 <- B1[,2] + 5* B1[,1]
B2 <- BETA2[,c("numpar:index_law_init","index_law_init")]
BB2 <- B2[,2] + 5* B2[,1]
dd <- (BB1) - (BB2)
# points(rep(y,N.sim)+rnorm(N.sim,sd=.25),
#        dd,
#        col=rgb(100,0,0,4,maxColorValue = 255), pch=19)
abline(h=0, col=rgb(100,0,0,255,maxColorValue = 255), lwd=2)
QQ <-  quantile(dd,c(0.005,0.025,0.975,0.995))
print(QQ)
segments(y-move.d,QQ[2],y-move.d,QQ[3],lwd=3,col=rgb(100,0,0,255,maxColorValue = 255))
segments(y-move.d,QQ[1],y-move.d,QQ[4],lwd=1,col=rgb(100,0,0,255,maxColorValue = 255))
print(y)
}
dev.off()
xtable(outi)
xtable(outi, file="out/table_3")
print(xtable(outi), file="out/table_3")
print(xtable(outi), file="out/table_3.tex")
# ------------------------------------------------------------------------------
# Replication Materials
#
# title: Coalition Size, Direct Democracy, and Public Spending
# journal: Journal of Public Policy
# authors: Patrick Emmenegger, Lucas Leemann, and André Walter
# date: Sept 2020
# ------------------------------------------------------------------------------
# Measure how long it takes to run code
start.time <- Sys.time()
# Load libraries
library(openxlsx)     # CRAN v4.1.5
library(lmtest)       # CRAN v0.9-37
library(dplyr)        # CRAN v1.0.2
library(tidyr)        # CRAN v1.1.1
library(ggplot2)      # CRAN v3.3.2
library(multiwayvcov) # CRAN v1.2.3
library(sandwich)     # CRAN v2.5-1
library(car)          # CRAN v3.0-9
library(lfe)          # CRAN v2.8-5.1
library(cowplot)      # CRAN v1.0.0
library(MASS)         # CRAN v7.3-52
library(extrafont)    # CRAN v0.17
library(AER)          # CRAN v1.2-9
library(texreg)       # CRAN v1.37.5
library(psych)        # CRAN v2.0.7
library(lme4)         # CRAN v1.1-23
library(brms)         # CRAN v2.13.5
library(xtable)       # CRAN v1.8-4
# Data
load("in/analysis_data.RData")
# Manipulation
source("01_Data_Manipulation.R")
# Descriptive Figures
source("01_Descriptive_Plots.R")
# Main Models
source("01_Main_Analysis.R")
# Result Stability?
source("01_Result_Stability.R")
# Appendix
source("01_Appendix.R")
# Measure how long it takes to run code
end.time <- Sys.time()
end.time - start.time
# ------------------------------------------------------------------------------
# Replication Materials
#
# title: Coalition Size, Direct Democracy, and Public Spending
# journal: Journal of Public Policy
# authors: Patrick Emmenegger, Lucas Leemann, and André Walter
# date: Sept 2020
# ------------------------------------------------------------------------------
# Measure how long it takes to run code
start.time <- Sys.time()
# Load libraries
library(openxlsx)     # CRAN v4.1.5
library(lmtest)       # CRAN v0.9-37
library(dplyr)        # CRAN v1.0.2
library(tidyr)        # CRAN v1.1.1
library(ggplot2)      # CRAN v3.3.2
library(multiwayvcov) # CRAN v1.2.3
library(sandwich)     # CRAN v2.5-1
library(car)          # CRAN v3.0-9
library(lfe)          # CRAN v2.8-5.1
library(cowplot)      # CRAN v1.0.0
library(MASS)         # CRAN v7.3-52
library(extrafont)    # CRAN v0.17
library(AER)          # CRAN v1.2-9
library(texreg)       # CRAN v1.37.5
library(psych)        # CRAN v2.0.7
library(lme4)         # CRAN v1.1-23
library(brms)         # CRAN v2.13.5
library(xtable)       # CRAN v1.8-4
# Data
load("in/analysis_data.RData")
# Manipulation
source("01_Data_Manipulation.R")
# Descriptive Figures
source("01_Descriptive_Plots.R")
# Main Models
source("01_Main_Analysis.R")
# Result Stability?
source("01_Result_Stability.R")
# Appendix
source("01_Appendix.R")
# Measure how long it takes to run code
end.time <- Sys.time()
end.time - start.time
